<template>
	<view class="">
			<cu-custom bgColor="bg-gradual-blue" :isBack="true">
				<block slot="backText">返回</block>
				<block slot="content">投诉建议</block>
			</cu-custom>
			<view class="padding flex flex-direction" :style="[{animation: 'show 0.5s 1'}]">
				<view class="cu-bar bg-white solid-bottom margin-top animation-scale-down"
					:style="[{animation: 'show 0.5s 1'}]">
					<view class="action">
						<text class="cuIcon-title text-orange"></text> 我的投诉
					</view>
					<uni-tag :text="'请新建'" type="default" :circle="true" :inverted="true" style="margin-right: 35px;" @click="onClick(0,0)"></uni-tag>
				</view>
				<uni-list v-for="item in listComplaint" :key = "item.id">
					<view class="" v-if="item.type == 0">
						<uni-list-item  :title="item.title" link @click="onClick(1,item)" >
							<template v-slot:footer>
								<view class="slot-box">
									<uni-tag :text="item.tag=='success'? '已解决' : item.tag=='warning'? '处理中' : '请新建'  " :type="item.tag" :circle="true" :inverted="true"></uni-tag>
								</view>
							</template>
						</uni-list-item>
					</view>
				</uni-list>
				<view class="cu-bar bg-white solid-bottom margin-top animation-scale-down"
					:style="[{animation: 'show 0.5s 1'}]">
					<view class="action">
						<text class="cuIcon-title text-green"></text> 我的建议
					</view>
					<uni-tag :text="'请新建'" type="default" :circle="true" :inverted="true" style="margin-right: 35px;" @click="onClick(0,0)"></uni-tag>
				</view>
				<uni-list v-for="item in listSuggestion" :key = "item.id">
					<view class="" v-if="item.type == 1">
						<uni-list-item  :title="item.title" link @click="onClick(1,item)" >
							<template v-slot:footer>
								<view class="slot-box">
									<uni-tag :text="item.tag=='success'? '已解决' : item.tag=='warning'? '处理中' : '请新建'  " :type="item.tag" :circle="true" :inverted="true"></uni-tag>
								</view>
							</template>
						</uni-list-item>
					</view>
				</uni-list>
			</view>
			<view>
				<uni-fab
					:pattern="pattern"
					:content="content"
					:horizontal="horizontal"
					:vertical="vertical"
					:direction="direction"
					@fabClick="trigger"
				></uni-fab>
			</view>
	</view>
</template>

<script>
	const stauts_type = [{text:'success',value:'已解决'},{text:'warning',value:'处理中'},{text:'default',value:'请新建'}];
	export default {
		name: 'complaintSuggestion',
		data() {
			return {
				horizontal: 'right',
				vertical: 'bottom',
				direction: 'horizontal',
				pattern: {
					color: '#7A7E83',
					backgroundColor: '#fff',
					selectedColor: '#007AFF',
					buttonColor: '#007AFF',
					iconColor: '#fff'
				},
				content: [],
				stauts_type,
				listComplaint:[
					{
						id: 1,
						title: "投诉1",
						tag: "success",
						type: 0,
					},
				],
				listSuggestion:[
					{
						id: 3,
						title: "建议2",
						tag: "success",
						type: 1,
					},
					{
						id: 4,
						title: "建议3",
						tag: "warning",
						type: 1,
					},
				],
			}
		},
		mounted() {
			this.getList()
		},
		activated() {
			this.getList()
		},
		methods: {
			getList() {
				this.$http.get(`/property/znzfComplaint/queryBySubmiter?Submiter=${this.$store.getters.userid}`).then(res => {
					if(res.data.result) {
						this.listComplaint = [],this.listSuggestion = []
						console.log(res.data.result)
						res.data.result.forEach(item => {
							let temp = {
								id: item.id,
								title: item.title,
								opinion: item.opinion,
								tag: item.opinion? "success":"warning",
								type: item.type,
								priority: 0,
								content: item.content
							}
							if(temp.type == 0)
								this.listComplaint.push(temp)
							else this.listSuggestion.push(temp)
						})
					}
				})
			},
			trigger() {
				console.log(1)
				this.$Router.push({
					name: 'addComplaintSuggestion'
				})
			},
			onClick(e,item) {
				// console.log(e)
				// if (item.tag == "default") {
				// 	this.$Router.push({name:'addComplaintSuggestion'})
				// }else {
				// 	let temp = this.list.filter(e => e.id == item.id)[0]data-type = ""
				if (e==0) this.$Router.push({name:'addComplaintSuggestion'})
				else this.$Router.push({name:'complaintSuggestionDetail', params:item})
				// }
			}
		},
	}
</script>

<style lang='scss'>
</style>
